package cn.slipi.admin.service.impl;

import cn.slipi.admin.common.exception.base.BizException;
import cn.slipi.admin.dao.TSysRoleAdminMapper;
import cn.slipi.admin.entity.TSysRoleAdmin;
import cn.slipi.admin.service.TSysRoleAdminService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 系统用户与角色对应关系表 服务实现类
 * </p>
 *
 * @author lee
 * @since 2020-10-09
 */
@Service
public class TSysRoleAdminServiceImpl extends ServiceImpl<TSysRoleAdminMapper, TSysRoleAdmin> implements TSysRoleAdminService {

    @Override
    @Transactional(rollbackFor = BizException.class)
    public List<TSysRoleAdmin> getRoleAdminByAdminId(Integer adminId) {
        /**
         * select ru from RoleAdmin ru where ru.AdminId = :AdminId and ru.status = 1
         */
        QueryWrapper<TSysRoleAdmin> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("ADMIN_ID", adminId);
        queryWrapper.eq("STATUS", 1);
        return this.baseMapper.selectList(queryWrapper);
    }
}
